package firstDay;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-05-24 17:10
 */
public class LeetCode242 {
    public static void main(String[] args) {
        boolean anagram = isAnagram("rat", "car");
        System.out.println(anagram);
    }
    public static boolean isAnagram(String s, String t) {

        int[] record = new int[26];
        for(int i = 0;i < s.length();i++){
            record[s.charAt(i) - 'a']++;
        }

        for(int i = 0;i < t.length();i++){
            record[t.charAt(i) - 'a']--;
        }

        for(int i = 0;i < record.length;i++){
            if (record[i] != 0){
                return false;
            }
        }
        return true;
    }
}

